home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F39138_zipWithDVC.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-16  |  1.9 KB  |  50 lines

  1. <xsl:stylesheet version="1.0"
  2.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. >
  4.   <xsl:template name="zipWith">
  5.     <xsl:param name="pFun" select="/.."/>
  6.     <xsl:param name="pList1" select="/.."/>
  7.     <xsl:param name="pList2" select="/.."/>
  8.     <xsl:param name="pElName" select="'el'"/>
  9.  
  10.     <xsl:if test="$pList1 and $pList2">
  11.       <xsl:variable name="vLength" select="count($pList1)"/>
  12.       <xsl:choose>
  13.           <xsl:when test="$vLength > 1">
  14.             <xsl:variable name="vHalf" select="floor($vLength div 2)"/>
  15.           
  16.               <xsl:call-template name="zipWith">
  17.                 <xsl:with-param name="pFun" select="$pFun"/>
  18.                 <xsl:with-param name="pList1" 
  19.                                 select="$pList1[position() <= $vHalf]"/>
  20.                 <xsl:with-param name="pList2" 
  21.                                 select="$pList2[position() <= $vHalf]"/>
  22.                 <xsl:with-param name="pElName" select="'el'"/>
  23.               </xsl:call-template>
  24.           
  25.               <xsl:call-template name="zipWith">
  26.                 <xsl:with-param name="pFun" select="$pFun"/>
  27.                 <xsl:with-param name="pList1" 
  28.                                 select="$pList1[position() > $vHalf]"/>
  29.                 <xsl:with-param name="pList2" 
  30.                                 select="$pList2[position() > $vHalf]"/>
  31.                 <xsl:with-param name="pElName" select="'el'"/>
  32.               </xsl:call-template>
  33.           </xsl:when>
  34.  
  35.           <xsl:otherwise>
  36.               <xsl:variable name="vFunResult">
  37.                 <xsl:apply-templates select="$pFun">
  38.                   <xsl:with-param name="pArg1" select="$pList1[1]"/>
  39.                   <xsl:with-param name="pArg2" select="$pList2[1]"/>
  40.                 </xsl:apply-templates>
  41.               </xsl:variable>
  42.         
  43.               <xsl:element name="{$pElName}">
  44.                 <xsl:copy-of select="$vFunResult"/>
  45.               </xsl:element>
  46.           </xsl:otherwise>
  47.       </xsl:choose>
  48.     </xsl:if>
  49.   </xsl:template>
  50. </xsl:stylesheet>